/*
*私募管理人 
*ManagerTable.js*/

import React, {Component,PropTypes} from 'react';
import {connect} from 'dva';
import {routerRedux,Link,withRouter } from 'dva/router';
import { Row,Col,Button, List, Avatar,Icon,Card,Collapse,Pagination,Popconfirm } from 'antd';
import AddPrivatePdt from '../../components/AddPrivatePdt';
import TakePartGame from './TakePartInGame';
import EditPrivateMan from './EditPrivateMan';
import TablePagination from '../../components/TablePagination';
import EditPrivatePdt from '../../components/EditPrivatePdt';
import NoData from '../../../../components/common/NoData';
import style from './managerTable.less';

const Panel = Collapse.Panel;

const ManagerTable =({dispatch,privateMger})=>{
	const { privateData,privatePage,isShowPdt,fundGameList} = privateMger;
	console.log('ManagerTable>',privateData)
	if(!_.isEmpty(privateData)){
		const data = privateData;
		const IconText = ({ type, text }) => (
		  //<span style={{marginRight:10}}>
		 <span style={{marginRight:52,fontSize:12}}>
		    {/*<Icon type={type} style={{ marginRight: 8 }} />*/}
			<Icon type={type} style={{ marginRight: 10,fontSize:14,color:"#4D89FF" }} />
		    {text}
		  </span>
		);
		
		function onClickMeta(){
			dispatch({
				type:'privateMger/setState',
				payload:{
					isShowPdt:true
				}
			})
		}
		function callback(key) {
		  console.log(key);
		}
		function deleteItem(v){
			dispatch({
				type:'privateMger/deleteManager',
				payload:{
					id:v
				}
			})
		}
		function deleteItemPdt(v){
			console.log('sddff',v)
			dispatch({
				type:'privateMger/deletePrivatePdt',
				payload:{
					id:v
				}
			})
		}
		const customPanelStyle = {
		  borderRadius: 0,
		  marginBottom: 0,
		  border: 0,
		  overflow: 'hidden',
		};
		return(
      <List
        className="demo-loadmore-list"
        itemLayout="horizontal"
        dataSource={data}
        footer={<div>
        	<TablePagination
        		page={privatePage}
        		tag='privateMger'
        		dispatch={dispatch}
        		className={style.TablePagina}
        	/>
        </div>}
        renderItem={(item,i) => (
          <Collapse 
          	key={`${item.id}`}
          	defaultActiveKey={['1']}
          	onChange={callback}
          	className={style.managerTable}
          >
				  <Panel
				    key={`${item.id}`}
				    showArrow={false}
				    style={customPanelStyle}
			    	header={[
			    		<Avatar size="large" icon="user" />,
		    			<span>{item.name}</span>,
		    			<span>{`私募产品 : ${item.pdtLen}`}</span>,
		    			<span style={{marginLeft:10}}>{`来源 : ${item.departmentName}`}</span>,<br/>,
		    			//<Row  gutter={8} style={{paddingLeft:70}}>
						<Row  gutter={8} style={{paddingLeft:36}}>
		    				<Col span={20} >
		    					<IconText type="user" text={item.contactName}/>
		    					<IconText type="barcode" text={item.creditCode} />
		    					<IconText type="phone" text={item.telephone} />
		          		<IconText type="mobile" text={item.mobile} />
									<IconText type="mail" text={item.email} />
		          		<IconText type="wechat" text={item.wechat}/>
		    				</Col>
		    				<Col span={4} style={{display:'flex',color:'#e5e7ea',position:'relative',top:-28}}>
		    					
		          		<EditPrivateMan
		          			data={item}
		          		/>&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;
		          		<Popconfirm title="确定删除?"  cancelText="取消" okText="确定" onConfirm={()=>deleteItem(item.id)}>
										<a style={{color:'#ff2f2f'}}>删除</a>
									</Popconfirm>
		    				</Col>
          			
          		</Row>
        		]}
				  >
				    <AddPrivatePdt CnameID= {item.id} Cname={item.name}/>
			    	{
			    		_.isEmpty(item.products)?<span>您还没有私募产品</span>:<List
            	dataSource={item.products}
            	className="privatePdt-list"
      				itemLayout="horizontal"
            	renderItem={item => (
              	<List.Item key={item.fundId}>
	              	<Row>
	              		<span>产品名称:</span>
		                <span>{item.productName}</span>
		                <span>投资策略:</span>
		                <span>{item.investStrategy}</span>
		                <span>备案码:</span>
		                <span className={style.spanText}>{item.recordCode}</span>
		                <EditPrivatePdt
											data={item}
										/>
										<Popconfirm title="确定删除?"  cancelText="取消" okText="确定" onConfirm={()=>deleteItemPdt(item.productId)}>
											<a>删除</a>
										</Popconfirm>
	              	</Row>
              	</List.Item>
	            	)}
	          	>
		          	</List>
				    	}
				    </Panel>
				  </Collapse>
        )}
      />
		)
	}else{
		return <NoData/>
	}
	
}

ManagerTable.propTypes = {}

export default connect(({privateMger})=>({privateMger}))(ManagerTable)